const state = () => ({
  authors:[],
  types:[],
  status:[],
  costIds:[]
})
const mutations = {
  setAuthors(state,val){
    state.authors = val
  },
  setTypes(state,val){
    state.types = val
  },
  setStatus(state,val){
    state.status = val
  },
  setCostIds(state,val){
    state.costIds = val
  }
}
const actions = {
  initStore(state){
    this.$axios.$get('http://localhost:8001/authors/getAllAuthors')
      .then(res => {
        state.commit('setAuthors',res)
      })
    this.$axios.$get('http://localhost:8001/types/getAllTypes')
      .then(res => {
        state.commit('setTypes',res)
      })
    this.$axios.$get('http://localhost:8001/status/getAllStatus')
      .then(res => {
        state.commit('setStatus',res)
      })
    this.$axios.$get('http://localhost:8001/costs/getAllCosts')
      .then(res => {
        state.commit('setCostIds',res)
      })
  }
}
export default {
  namespace:true,
  state,
  mutations,
  actions
}
